package com.haoran.dwz.domain.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.springframework.format.annotation.DateTimeFormat;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

@Entity
@Table(name = "t_short_url")
@ApiModel("短链接")
public class ShortURL extends PeriodFilterEntity{
	
	@Id
	@ApiModelProperty("短链接唯一标识")
	private long id;
	
	@ApiModelProperty(value = "短网址",required=true)
	@Column(unique = true,nullable=false,columnDefinition="VARCHAR(32) BINARY")
	private String dwz;
	
	@ApiModelProperty(value = "短链接对应的原始链接",required=true)
	@Column(unique = true,nullable=false,columnDefinition="VARCHAR(512) BINARY")
	private String url;
	
	@ApiModelProperty(value="短链接创建时间",example="yyyy-MM-dd HH:mm:ss")
	@Column(name = "create_time")
	@Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime = new Date();
	
	@ApiModelProperty(value="短链接失效时间",example="yyyy-MM-dd HH:mm:ss")
	@Column(name = "expire_time")
	@Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date expireTime;
	
	@ApiModelProperty(value="短链接最后一次使用时间",example="yyyy-MM-dd HH:mm:ss")
	@Column(name = "last_used_time")
	@Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date lastUsedTime;

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getExpireTime() {
		return expireTime;
	}

	public void setExpireTime(Date expireTime) {
		this.expireTime = expireTime;
	}

	public Date getLastUsedTime() {
		return lastUsedTime;
	}

	public void setLastUsedTime(Date lastUsedTime) {
		this.lastUsedTime = lastUsedTime;
	}

	public String getDwz() {
		return dwz;
	}

	public void setDwz(String dwz) {
		this.dwz = dwz;
	}
}
